﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ParkingLot.Entitys.AbstractEntitys;
using ParkingLot.Entitys.Enums;
using ParkingLot.Utility.Extend;

namespace ParkingLot.Utility.LogHelps
{
    /// <summary>
    /// 日志实体类,用来写日志
    /// </summary>
    public class LogEncity : CloneableObject
    {
        public string SaveFileName = "None.txt";

        /// <summary>
        /// 类别列表
        /// </summary>
        public List<string> lisCategories=new List<string>();

        /// <summary>
        /// 日志时间
        /// </summary>
        public DateTime LogTime = DateTime.MaxValue.GetCurTime();

        /// <summary>
        /// 日志ID
        /// </summary>
        public string LogID =Guid.NewGuid().ToString();

        /// <summary>
        /// 联系ID
        /// </summary>
        public string RelationID;

        /// <summary>
        /// 日志类型
        /// </summary>
        public LogType LogType = LogType.SysRun;

        /// <summary>
        /// 消息
        /// </summary>
        public string Message;

        public LogEncity()
        {
            LogType = LogType.SysRun;
            AddCategories();
        }

        public LogEncity(Exception exception)
        {
            LogType = LogType.Error;
            Message = exception.ToString();
            AddCategories();
        }

        public LogEncity(string explan,Exception exception)
        {
            LogType = LogType.Error;
            Message = explan+ exception.ToString();
            AddCategories();
        }

        public LogEncity(string message)
        {
            LogType = LogType.Error;
            Message = message;
            AddCategories();
        }

        /// <summary>
        /// 虚方法 添加类别
        /// </summary>
        public virtual void AddCategories()
        {
            
        }

        #region 转换器
        public static implicit operator LogEncity(string message)
        {
            return new LogEncity(message);
        }

        public static implicit operator LogEncity(Exception exception)
        {
            return new LogEncity(exception);
        }
        #endregion


    }

   
}
